package org.apache.ibatis.luban;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.luban.entity.Blog;
import org.apache.ibatis.luban.mapper.BlogMapper;
import org.apache.ibatis.session.*;

import java.io.InputStream;

public class MyBatisDemo1 {
  public static void main(String[] args) throws Exception {
    String resource = "mybatis-config.xml";
    InputStream inputStream = Resources.getResourceAsStream(resource);
    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
    SqlSession sqlSession = sqlSessionFactory.openSession();
    BlogMapper blogMapper = sqlSession.getMapper(BlogMapper.class);
    blogMapper.selectBlog(572);
//    sqlSession.close();
//
//    sqlSession = sqlSessionFactory.openSession();
//    blogMapper = sqlSession.getMapper(BlogMapper.class);
    blogMapper.selectBlog(572);
    sqlSession.close();
  }
}
